//初始化页面
$(function() {
	var url = "getSettingAction";
	$.post(url, "", callback, "json");
	function callback(json) {
		var json_object = eval("(" + json + ")");
		var suc = json_object.suc;
		if (suc == 0) {
			return;
		} else {
			var maxDays = json_object.maxDays;
			var maxBorrow = json_object.maxBorrow;
			$("#maxDays").val(maxDays);
			$("#maxBorrow").val(maxBorrow);
		}
	}
});

//提交设置
function submitSettings() {

	var url = "settingsAction";
	var maxDays = $("#maxDays").val();
	var maxBorrow = $("#maxBorrow").val();
	if (maxDays == "") {
		alert("天数不能为空");
		return;
	}
	if (maxBorrow == "") {
		alert("书目不能为空");
		return;
	}
	var json_settings = {
		maxDays : maxDays,
		maxBorrow : maxBorrow
	};

	$.post(url, json_settings, callback, "json");

	function callback(json) {
		var json_object = eval("(" + json + ")");
		var suc = json_object.suc;
		if (suc == 0) {
			alert("修改失败：" + json_object.msg);
		} else {
			alert("修改成功");
			window.location.reload();
		}
	}
}
